/**
 * 文件名：ResourceManager.java
 * 创建时间：Jul 7, 200912:31:29 PM
 */
package com.lane.sidecn.security.service;

import com.lane.core.dao.HibernateEntityDao;
import com.lane.sidecn.security.model.Resource;
import com.lane.sidecn.security.model.Role;

/**
 * @author 忽吉烈
 *
 */
public class ResourceManager extends HibernateEntityDao<Resource> {

	/**
	 * 删除资源，并且从拥有该资源的角色中删除该资源
	 * @param id
	 */
	public void delete(Integer id)
	{
		Resource resource = get(id);
		for(Role role : resource.getRoles())
		{
			role.getResources().remove(resource);
		}
		super.remove(resource);
	}
}
